﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Physis.Core {

    public class CoreFactory : FactoryBase {
        
        #region Private Properties

        private Entity.EntityFactory entityFactory = null;

        private General.GeneralFactory generalFactory = null;

        private Insurer.InsurerFactory insurerFactory = null;

        private Sponsor.SponsorFactory sponsorFactory = null;

        #endregion 


        #region Public Properties

        public Entity.EntityFactory Entity { get { return entityFactory; } }

        public General.GeneralFactory General { get { return generalFactory; } }

        public Insurer.InsurerFactory Insurer { get { return insurerFactory; } }

        public Sponsor.SponsorFactory Sponsor { get { return sponsorFactory; } }

        #endregion 


        #region Constructors

        public CoreFactory (Application forApplication) : base (forApplication) { 

            entityFactory = new Entity.EntityFactory (Application);

            generalFactory = new Core.General.GeneralFactory (Application);

            insurerFactory = new Insurer.InsurerFactory (Application);

            sponsorFactory = new Sponsor.SponsorFactory (Application);

            return;

        }

        #endregion 


        #region Factories

        public Dictionary<String, String> CoreObjectDictionarySerializable (List<CoreObject> coreObjects) {

            Dictionary<String, String> dictionary = new Dictionary<String, String> ();

            coreObjects = coreObjects.OrderBy (coreObject => coreObject.Name).ToList ();

            foreach (CoreObject currentCoreObject in coreObjects) {

                dictionary.Add (currentCoreObject.Id.ToString (), currentCoreObject.Name);

            }

            return dictionary;

        }

        #endregion 

    }

}
